package cn.tedu.boot01.Controller;

import cn.tedu.boot01.entity.Emp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author 作者：HeShaoShuai
 * @Email 邮箱：2569819541@qq.com
 * @Date 日期：2023/5/10 19:54
 * @Package 包名：cn.tedo.boot01.Controller
 * @Project 项目名：JavaSE
 * @Version 1.0
 */
@Controller
public class ParamController {
	@RequestMapping("/p1")
	@ResponseBody
	public String p1(HttpServletRequest request){
		String name = request.getParameter("name");
		String age = request.getParameter("age");
		return name+":"+age;
	}
	@RequestMapping("/p2")
	@ResponseBody
	public String p2(String name,int age){
		return name+":"+age;
	}
	@RequestMapping("/p3")
	@ResponseBody //内部是通过SpringMVC框架+反射的方式获取传递过来的参数并赋值给了Emp对象
	public String p3(Emp emp){
		return emp.toString();
	}
}
